package com.wh1200.xmlless.test.dao

import com.wh1200.mybatis.xmlless.XmlLessMapper
import com.wh1200.mybatis.xmlless.annotations.XmllessMethod
import com.wh1200.mybatis.xmlless.enums.QueryType
import com.wh1200.xmlless.test.model.Dog
import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Param

/**
 *
 * Created by 吴昊 on 2018-12-12.
 *
 * @author 吴昊
 * @since 0.0.4
 */
@Mapper
interface DogDAO : XmlLessMapper<Dog>, com.wh1200.xmlless.test.dao.BaseDAO<Dog, Int> {

  /**
   * @param id
   * @return
   */
  fun deleteById(@Param("id") id: Int): Int

  /**
   * @param id
   * @return
   */
  @XmllessMethod(
      type = QueryType.Delete,
      conditions = ["id"]
  )
  fun deleteLogicById(@Param("id") id: Int): Int

  /**
   * @param id
   * @return
   */
  fun existsById(@Param("id") id: Int): Boolean

  /**
   * @param name
   * @return
   */
  fun findByName(@Param("name") name: String): Dog?

  /**
   * @param names
   * @return
   */
  fun findByNamesIn(@Param("names") names: List<String>): List<Dog>

  /**
   * @param ages
   * @return
   */
  fun findByAgesIn(@Param("ages") ages: List<Int>): List<Dog>

}
